<%@page pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%><!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
	.tree-node {padding:0;}
</style>
  </head>
  <body>
  	<div class="easyui-layout" data-options="fit:true">
		<div data-options="region:'north',border:false">
			<fieldset>
    		<legend>过滤条件</legend>
    		<table style="width:100%">
    			<tr>条件查询</tr>
    		</table>
  		</fieldset>
		</div>
  		<div data-options="region:'center',border:false" style="padding-bottom: 33px">
            <div id="toolbar_articleTable" class="toolbar"></div>
  			<table id="article_datagrid"></table>
		</div>
	</div>
	<script>
		$(function(){
			$('# ').toolbar({buttons:[
	           	{name:'save_category',iconCls:'icon-ok',text:'投稿'},
	      	],handler:handler});
			
		    $('#article_datagrid').datagrid({
		    	url:'page',
	    		pagination:true,
	    		singleSelect:true,
	    		rownumbers:false,
	    		striped:true,
	    		fit:true,
	    		fitColumns:true,
	    		toorbar:'#toolbar_articleTable',
	    		columns:[[
	    			{field:'id',title:'编号'},
	    			{field:'articleTitle',title:'文章标题'},
	        		{field:'userName',title:'作者'},
	        		{field:'articleType',title:'类型',formatter:function(v,r,i){
	        			var type ="";
	        			if(r.articleType == "1"){type ="文章"}else if(r.articleType == "3"){type ="音频"}else if(r.articleType == "5"){type="视频"}else if(r.articleType == "7"){type="话题pk"}
	        			return type;
	        		}},
	        		{field:'markPublish',title:'发布标记'},
	        		{field:'countView',title:'浏览量'},
	        		{field:'countPraise',title:'点赞量'},
	        		{field:'countShare',title:'分享量'},
	        		{field:'countCollect',title:'收藏量'},
	        		{field:'markAudit',title:'审核标记'},
	        		{field:'enabled',title:'是否可用',formatter:function(v,r,i){
	        			var enab = '否';
	        			if(r.enabled){
	        				enab = '是'
	        			}
	        			return enab;
	        		}},
	        		{field:'createdDt',title:'创建时间'},
	        		{field:'-',title:'操作',align:'center',formatter:function(v,r,i){
	        			var action = '<a href="#" onclick="toEdit('+r.id+');">编辑</a>&nbsp;&nbsp;';
	        			if(r.enabled){
	        				action = action+'<a href="#" onclick ="enabled('+r.id+');">禁用</a>';
	        				action = action+'&nbsp;&nbsp;<a href="#" onclick="addCategory('+i+');">去投稿</a>';
	        			}else{
	        				action = action+'<a href="#" onclick="disbled('+r.id+');">启用</a>';
	        				
	        			}
	        			action = action+'&nbsp;&nbsp;<a href="#">查看</a>';
	        			
						return action;
					}}
	    		]],
	    		view: detailview,
	    	    detailFormatter: function(rowIndex, rowData){
	    	        return '<table><tr>' +
	    	                '<td rowspan=2 style="border:0,height:50px;">'+rowData.articleContent+'</td>' +
	    	                '</tr></table>';
	    	    }
			 });
		});
		

		
		function toSearch() {
			$('#grid').treegrid('load',$('#qform').serializeArray());
		}
		
		function toAdd() {
			show({code:'admin_user_add',title:'添加用户信息',iconCls:'icon-add',uri:'add',width:800,height:600,
				options : {
					success : function(data) { 
						$('#grid').datagrid('reload'); 
					}
				}
			});
		}

		function toEdit(item) {
			show({code:'admin_user_edit',title:'编辑用户信息',iconCls:'icon-edit',uri:'edit?id='+item.id,width:800,height:600,
				options : {
					success : function(data) { 
						$('#grid').datagrid('reload'); 
					}
				}
			});
		}
		
		function toDel(item) {
			$confirm('您确定要删除“'+item.modelName+'”模块信息吗？',function() {
				$.post('delete?id='+item.id,function(r) {
					if(r.code <= 0) return $error(r.msg);
					$('#grid').datagrid('reload');
					$prompt('删除成功');
				},'json');
			});
		}

		
		function doSave() {
			$.submit('#dataform',function(r) {
				if(r.code<0) return $alert(r.msg);
				$('#dialog').dialog('close');
				$('#grid').datagrid('reload');
				$prompt('保存成功');
			});
		}
	</script>
  </body>
</html>